package com.tj.jinzao.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.tj.jinzao.R;
import com.tj.jinzao.base.BaseListAdapter;

import java.util.concurrent.CopyOnWriteArrayList;


/**
 * 我的item Adapter
 * Created by wjy on 2018/10/15.
 */
public class MeAdapter extends BaseListAdapter<Pair, MeAdapter.ViewHolder> {


    public MeAdapter(Context context, CopyOnWriteArrayList data) {
        super(context, data);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_me, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Pair<Integer, String> pair = mData.get(position);
        holder.icon.setImageResource(pair.first);
        holder.name.setText(pair.second);
        holder.blank.setVisibility(position == 4 ? View.VISIBLE : View.GONE);
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        ImageView icon;
        View blank;

        public ViewHolder(View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.tv_name);
            icon = itemView.findViewById(R.id.iv_icon);
            blank = itemView.findViewById(R.id.blank);
        }
    }
}
